﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.plaf.basic.icon {
    import flash.display.*;
    import flash.geom.*;
    import org.aswing.*;
    import flash.filters.*;
    import org.aswing.plaf.*;
    import org.aswing.graphics.*;
    import org.aswing.plaf.basic.*;

    public class CheckBoxIcon implements Icon, UIResource {

        protected var sprite:Sprite;
        protected var box:Shape;
        protected var dot:Shape;

        public function CheckBoxIcon(){
            this.sprite = new Sprite();
            this.sprite.mouseChildren = false;
            this.sprite.mouseEnabled = false;
            this.box = new Shape();
            this.dot = new Shape();
            this.sprite.addChild(this.box);
            this.sprite.addChild(this.dot);
        }
        public function updateIcon(_arg1:Component, _arg2:Graphics2D, _arg3:int, _arg4:int):void{
            var _local11:StyleResult;
            var _local18:StyleResult;
            var _local19:Matrix;
            var _local5:AbstractButton = AbstractButton(_arg1);
            var _local6:ButtonModel = _local5.getModel();
            var _local7:Boolean = _local6.isSelected();
            this.box.graphics.clear();
            _arg2 = new Graphics2D(this.box.graphics);
            var _local8:int = (this.getIconWidth(_arg1) - 5);
            var _local9:int = (this.getIconHeight(_arg1) - 5);
            _arg3 = (_arg3 + 1);
            _arg4 = (_arg4 + 3);
            var _local10:ASColor = _arg1.getBackground();
            var _local12:StyleTune = _arg1.getStyleTune();
            var _local13:Boolean = ((_local6.isArmed()) || (_local6.isSelected()));
            var _local14:Number = 1;
            var _local15:Number = 2;
            var _local16:Number = 1;
            if (_local13){
                _local15 = 3;
                var _temp1 = _local12.clone();
                _local12 = _local12.clone();
                _temp1.bGradient = (_local12.bGradient * 0.8);
                _local12.cGradient = (_local12.cGradient * 0.8);
                if (!_local5.isEnabled()){
                    _local10 = _local10.offsetHLS(0, 0, -0.03);
                    _local12 = _local12.sharpen(0.6);
                    _local16 = 0.5;
                } else {
                    if (_local6.isRollOver()){
                        _local10 = _local10.offsetHLS(0, 0.06, 0.06);
                        _local12 = _local12.sharpen(0.8);
                        _local15 = 4;
                    } else {
                        if (_local6.isArmed()){
                            _local12 = _local12.sharpen(0.8);
                        };
                    };
                };
            } else {
                if (!_local5.isEnabled()){
                    _local10 = _local10.offsetHLS(0, -0.06, -0.03);
                    _local12 = _local12.sharpen(0.6);
                    _local16 = 0.5;
                } else {
                    if (_local6.isRollOver()){
                        _local10 = _local10.offsetHLS(0, 0.06, 0.06);
                        _local15 = 4;
                    };
                };
            };
            _local11 = new StyleResult(_local10, _local12);
            _arg2.beginFill(new SolidBrush(_local11.bdark));
            BasicGraphicsUtils.drawRoundRect(_arg2, _arg3, _arg4, _local8, _local9, _local11.round);
            _arg2.endFill();
            _arg2.beginFill(new SolidBrush(_local11.clight));
            var _local17:Number = (_local11.round - 1);
            _local17 = Math.max(0, _local17);
            BasicGraphicsUtils.drawRoundRect(_arg2, (_arg3 + 1), (_arg4 + 1), (_local8 - 2), (_local9 - 2), _local17);
            _arg2.endFill();
            this.dot.graphics.clear();
            if (_local7){
                _arg2 = new Graphics2D(this.dot.graphics);
                _local10 = _arg1.getMideground();
                _local12 = _arg1.getStyleTune().mide;
                if (_local6.isArmed()){
                    _local10 = _local10.offsetHLS(0, -0.04, 0.03);
                } else {
                    if (_local6.isRollOver()){
                        _local10 = _local10.offsetHLS(0, 0.06, 0);
                        _local12 = _local12.sharpen(0.8);
                    } else {
                        if (!_local5.isEnabled()){
                            _local10 = _local10.offsetHLS(0, 0, -0.3);
                            _local12 = _local12.sharpen(0.6);
                        };
                    };
                };
                _local18 = new StyleResult(_local10, _local12);
                _local19 = new Matrix();
                _local19.createGradientBox(((_local8 / 2) - 3), (((_local9 * 3) / 4) - 5), ((Math.PI * 3) / 4), (_arg3 + 3), (_arg4 + 5));
                this.dot.graphics.lineStyle(1.5, _local10.getRGB());
                _arg2.moveTo((_arg3 + 4), (_arg4 + 5));
                _arg2.lineTo(((_arg3 + (_local8 / 2)) + 1), ((_arg4 + ((_local9 * 3) / 4)) - 1));
                _local19.createGradientBox((_local8 / 2), (((_local9 * 3) / 4) - 2), (Math.PI / 4), (_arg3 + (_local8 / 2)), (_arg4 + 2));
                _arg2.lineTo(((_arg3 + _local8) + 2.5), _arg4);
                _arg2.endDraw();
                this.dot.filters = [new DropShadowFilter(0, 45, _local18.bdark.getRGB(), _local18.shadow, 2, 2, 4, 1, false)];
            };
            this.dot.visible = _local7;
            this.box.alpha = _local16;
            this.box.filters = [new DropShadowFilter(_local15, 45, 0, (_local11.shadow * _local14), 5, 5, 1, 1, true), new BevelFilter(1, 45, 0, _local11.shadow, 0xFFFFFF, _local11.shadow, 3, 3, 1, 1, BitmapFilterType.FULL)];
        }
        public function getIconHeight(_arg1:Component):int{
            return (17);
        }
        public function getIconWidth(_arg1:Component):int{
            return (17);
        }
        public function getDisplay(_arg1:Component):DisplayObject{
            return (this.sprite);
        }

    }
}//package org.aswing.plaf.basic.icon 
